//
//  lunBo.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/16.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "lunBo.h"
#import "Myscroler.h"
@interface lunBo()<UIScrollViewDelegate>
@property (nonatomic,retain)Myscroler *scroller;
@property (nonatomic,retain)UIPageControl *page;
@end
@implementation lunBo

-(void)dealloc{
    
    [_scroller release];
    [_page release];
    [super dealloc];
    
}



-(instancetype)initWithFrame:(CGRect)frame withImages:(NSArray<UIImage*>*)images{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self cofigWithFrame:frame withImages:images];
    }
    return self;
}

-(void)cofigWithFrame:(CGRect)frame withImages:(NSArray<UIImage*>*)images{
    
    //创建对象
    self.scroller = [[Myscroler alloc]initWithFrame:frame withImages:images];
    [self addSubview:self.scroller];
    [self.scroller release];
    self.scroller.delegate = self;
    //设置缩放比例
    self.scroller.maximumZoomScale = 2;
    self.scroller.minimumZoomScale = 0.5;
    
    //创建Pagecontrol
    self.page = [[UIPageControl alloc]initWithFrame:CGRectMake(0, frame.size.height-40, frame.size.width, 40)];
    self.page.numberOfPages = images.count;
    self.page.currentPageIndicatorTintColor = [UIColor blueColor];
    [self.page addTarget:self action:@selector(handle:) forControlEvents:UIControlEventValueChanged];
    
    [self.page release];
}

//圆点跟图片保持一致


-(void)handle:(UIPageControl*)page{
    [self.scroller setContentOffset:CGPointMake(page.currentPage*self.bounds.size.width, 0) animated:YES];
}














@end
